package com.pounds.control;

import com.pounds.pojo.User;
import com.pounds.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("peaceful/user")
public class UserControl {

    @Autowired
    private UserService userService;

    @GetMapping("select")
    public List<User> getUserList() {
        return userService.getUserList();
    }

    @GetMapping("new")
    public String addUser(String name, String sex, int age, String address, String contact, String admin, String link, String need, String note) {
        return userService.addUser(name, sex, age, address, contact, admin, link, need, note);
    }

    @GetMapping("delete")
    public String deleteUser(int id) {
        return userService.deleteUser(id);
    }

    @GetMapping("update")
    public String updateUser(int id, String name, String sex, int age, String address, String contact, String admin, String link, String need, String note) {
        return userService.updateUser(id, name, sex, age, address, contact, admin, link, need, note);
    }
}
